/*
 * @Author: wupeiwen <javapeiwen2010@gmail.com>
 * @Date: 2022-04-12 17:46:21
 * @LastEditors: wupeiwen <javapeiwen2010@gmail.com>
 * @LastEditTime: 2023-07-03 14:18:06
 * @FilePath: /tea-garden-web/src/util/dict.js
 * @Description: 前端字典
 */
// 字典-月
export const months = { 1: '一月', 2: '二月', 3: '三月', 4: '四月', 5: '五月', 6: '六月', 7: '七月', 8: '八月', 9: '九月', 10: '十月', 11: '十一月', 12: '十二月' }
// 字典-周
export const weekDays = { 1: '周一', 2: '周二', 3: '周三', 4: '周四', 5: '周五', 6: '周六', 7: '周日' }
// 图例-长势与水肥（整体）
export const legend1 = [{ color: '#00FF5A', name: '优越' }, { color: '#00F1FF', name: '良好' }, { color: '#FFF500', name: '适中' }, { color: '#FF0000', name: '较差' }]
// 图例-长势与水肥（水分、养分）
export const legend2 = [{ color: '#00FF5A', name: '正常' }, { color: '#00F1FF', name: '轻度' }, { color: '#FFF500', name: '中度' }, { color: '#FF0000', name: '重度' }]
// 图例-采摘期预测
export const legend3 = [{ color: '#369AFE', name: '较远' }, { color: '#FEAD54', name: '中期' }, { color: '#FF6B6B', name: '较近' }, { color: '#00FF5A', name: '结束' }]
// 图例-采摘完成率
export const legend4 = [{ color: 'rgba(189, 196, 206, 1)', name: '100%' }, { color: 'rgba(255, 107, 107, 0.25)', name: '75%' }, { color: 'rgba(255, 107, 107, 0.5)', name: '50%' }, { color: 'rgba(255, 107, 107, 0.75)', name: '25%' }, { color: 'rgba(255, 107, 107, 1)', name: '0%' }]
// 图例-病虫害（整体）
export const legend5 = [{ color: '#00FF5A', name: '健康' }, { color: '#ccc', name: '轻度' }, { color: '#FFF500', name: '中度' }, { color: '#FF0000', name: '重度' }]
// 图例-病虫害（茶小绿叶蝉、茶炭疽）
export const legend6 = [{ color: '#00FF5A', name: '健康' }, { color: '#ccc', name: '轻度' }, { color: '#FFF500', name: '中度' }, { color: '#FF0000', name: '重度' }]
// 气象灾害（霜冻害、热害）
export const legend7 = [{ color: '#FFFFFF', name: '无' }, { color: '#00FF5A', name: '轻度' }, { color: '#FFF500', name: '中度' }, { color: '#FF0000', name: '重度' }]
// id: 63, name: '病虫害-整体'
// id: 70, name: '病虫害-气象灾害-单体'
// id: 75, name: '整体长势'
// id: 80, name: '土壤养分与水分'
// id: 106, name: '气象灾害'
export const colorChange = { 1: '#FF6B6B', 2: '#FFAC54', 3: '#369BFF', 4: '#1FD1A5' }
export const color = { 64: '#BCC8CC', 65: '#1FD1A5', 66: '#369BFF', 67: '#FFAC54', 68: '#FF6B6B', 69: '#FF0000', 71: '#BCC8CC', 72: '#1FD1A5', 73: '#FFAC54', 74: '#FF6B6B', 76: '#1FD0A3', 77: '#369BFF', 78: '#FFAC54', 79: '#FF6B6B', 81: '#1FD1A5', 82: '#369BFF', 83: '#FFAC54', 105: '#FF6B6B' }
export const color2 = { 64: '#FFFFFF', 65: '#00FF5A', 66: '#00F1FF', 67: '#FFF500', 68: '#FF0000', 69: '#9E00FF', 71: '#FFFFFF', 72: '#00FF5A', 73: '#FFF500', 74: '#FF0000', 76: '#00FF5A', 77: '#00F1FF', 78: '#FFF500', 79: '#FF0000', 81: '#00FF5A', 82: '#00F1FF', 83: '#FF0000', 105: '#FFF500', 100: '#FF6B6B', 101: '#FEAD54', 102: '#369AFE', 103: '#00FF5A', 107: '#FFFFFF', 108: '#00FF5A', 109: '#FFF500', 110: '#FF0000' }
export const icon = { 64: '01', 65: '02', 66: '03', 67: '04', 68: '05', 69: '06', 71: '01', 72: '02', 73: '04', 74: '05', 76: '02', 77: '03', 78: '04', 79: '05', 81: '02', 82: '03', 105: '04', 83: '05' }
// 风速
export const windSpeed2 = (speed) => {
  if (speed === '-' || speed > 999 || isNaN(speed)) { return '-' }
  if (speed <= 0.2) { return '微风' } else if (speed <= 1.5 && speed > 0.2) { return '1级' } else if (speed <= 3.3 && speed > 1.5) { return '2级' } else if (speed <= 5.4 && speed > 3.3) { return '3级' } else if (speed <= 7.9 && speed > 5.4) { return '4级' } else if (speed <= 10.7 && speed > 7.9) { return '5级' } else if (speed <= 13.8 && speed > 10.7) { return '6级' } else if (speed <= 17.1 && speed > 13.8) { return '7级' } else if (speed <= 20.7 && speed > 17.1) { return '8级' } else if (speed <= 24.4 && speed > 20.7) { return '9级' } else if (speed <= 28.4 && speed > 24.4) { return '10级' } else if (speed <= 32.6 && speed > 28.4) { return '11级' } else if (speed <= 132 && speed > 32.6) { return '12级以上' } else { return '' }
}
// 风向
export const windDri2 = function (degree) {
  if (degree > 999) { return '--' }
  try {
    degree = +degree
  } catch (e) {
    return '静风'
  }
  if ((degree > 348.75 && degree <= 360) || degree <= 11.25) {
    return '北风'
  } else if (degree > 11.25 && degree <= 33.75) {
    return '北偏东'
  } else if (degree > 33.75 && degree <= 56.25) {
    return '东北风'
  } else if (degree > 56.25 && degree <= 78.75) {
    return '东偏北'
  } else if (degree > 78.75 && degree <= 101.25) {
    return '东风'
  } else if (degree > 101.25 && degree <= 123.75) {
    return '东偏南'
  } else if (degree > 123.75 && degree <= 146.25) {
    return '东南风'
  } else if (degree > 146.25 && degree <= 168.75) {
    return '南偏东'
  } else if (degree > 168.75 && degree <= 191.25) {
    return '南风'
  } else if (degree > 191.25 && degree <= 213.75) {
    return '南偏西'
  } else if (degree > 213.75 && degree <= 236.25) {
    return '西南风'
  } else if (degree > 236.25 && degree <= 258.75) {
    return '西偏南'
  } else if (degree > 258.75 && degree <= 281.25) {
    return '西风'
  } else if (degree > 281.25 && degree <= 303.75) {
    return '西偏北'
  } else if (degree > 303.75 && degree <= 326.25) {
    return '西北风'
  } else if (degree > 326.25 && degree <= 348.75) {
    return '北偏西'
  }
}
// 日期格式化
export const formatDate = (originalDateTime) => {
  // 原始的日期时间字符串（格式为 "YYYYMMDDHHmmss"）
// const originalDateTime = "20230626081421";

  // 将原始字符串拆分为年、月、日、时、分、秒的部分
  const year = originalDateTime.slice(0, 4)
  const month = originalDateTime.slice(4, 6)
  const day = originalDateTime.slice(6, 8)
  const hour = originalDateTime.slice(8, 10)
  const minute = originalDateTime.slice(10, 12)
  const second = originalDateTime.slice(12, 14)

  // 创建一个新的 Date 对象，并设置年、月、日、时、分、秒
  const date = new Date(year, parseInt(month) - 1, day, hour, minute, second)

  // 将时区调整为 UTC+8
  date.setUTCHours(date.getUTCHours() + 8)

  // 获取年、月、日的部分
  const year1 = date.getFullYear()
  const month1 = ('0' + (date.getMonth() + 1)).slice(-2)
  const day1 = ('0' + date.getDate()).slice(-2)
  const hour1 = ('0' + date.getHours()).slice(-2)
  const minute1 = ('0' + date.getMinutes()).slice(-2)
  const second1 = ('0' + date.getSeconds()).slice(-2)
  // 格式化为 "YYYY-MM-DD HH:mm:ss" 的字符串
  const formattedDateTime = year1 + '-' + month1 + '-' + day1 + ' ' + hour1 + ':' + minute1 + ':' + second1
  return formattedDateTime
}
